/**
 * @项目名称: shaoshaohuo 
 * @文件名称: PayResultActivity.java 
 * @Date: 2015年12月17日 
 * @Copyright: 2015 www.longinf.com Inc. All rights reserved. 
 * 注意：本内容仅限于北京龙息科技有限公司内部传阅，禁止外泄以及用于其他的商业目的
 */
package com.shaoshaohuo.app.ui.pay;

import com.shaoshaohuo.app.R;
import com.shaoshaohuo.app.framework.IViewFramework;
import com.shaoshaohuo.app.ui.BaseActivity;
import com.shaoshaohuo.app.view.TopbarView;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * @Project: shaoshaohuo 
 * @Author: Osborn 
 * @Date: 2015年12月17日 
 */
public class RechargeResultActivity extends BaseActivity implements IViewFramework {

	/**
	 * extra 传入的对象的key
	 */
	public static final String FORWARD_KEY = "FORWARD_KEY";
	/**
	 * 关闭后，跳转到用户我的界面
	 */
	public static final String FORWARD_USER_MAIN = "FORWARD_USER_MAIN";
	
	/**
	 * 从打开支付结果页面的源，获取的传参
	 */
	private String contextForward;
	public static final String KEY_RESULT = "KEY_RESULT";
	public static final String KEY_MONEY = "KEY_MONEY";
	public static final String KEY_ORDER_ID = "KEY_ORDER_ID";
	public static final String KEY_PAY_WAY = "KEY_PAY_WAY";
	public static final String KEY_PAY_TIME = "KEY_PAY_TIME";
	
	public static final String KEY_FAILURE_REASON = "KEY_FAILURE_REASON";
	
	public static final String VALUE_SUCCESS = "SUCCESS";
	public static final String VALUE_FAILURE = "FAILURE";
	
	
	private TopbarView topBar;
	private LinearLayout layoutSuccess;

	private LinearLayout layoutFailure;

	private TextView tvPayMoney;

	private TextView tvPayWay;

	private TextView tvPayOrderId;

	private TextView tvPayTime;

	private TextView tvPayFailureReason;

	/* (non-Javadoc)
	 * @see com.shaoshaohuo.app.ui.BaseActivity#onCreate(android.os.Bundle)
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_recharge_result);
		init();
	}

	/* (non-Javadoc)
	 * @see com.shaoshaohuo.app.framework.IViewFramework#init()
	 */
	@Override
	public void init() {
		initView();
		initData();
		initListener();
	}

	/* (non-Javadoc)
	 * @see com.shaoshaohuo.app.framework.IViewFramework#initView()
	 */
	@Override
	public void initView() {
		topBar = (TopbarView) findViewById(R.id.topbar);
		
		topBar.setCenterText("交易详情");
		topBar.setRightImage(R.drawable.icon_close_trade_ad);
		layoutSuccess = (LinearLayout) findViewById(R.id.pay_success);
		layoutFailure = (LinearLayout) findViewById(R.id.pay_failure);
		tvPayMoney = (TextView) findViewById(R.id.pay_money);
		tvPayWay = (TextView) findViewById(R.id.pay_way);
		tvPayOrderId = (TextView) findViewById(R.id.pay_order_id);
		tvPayTime = (TextView) findViewById(R.id.payTime);
		tvPayFailureReason = (TextView) findViewById(R.id.pay_failure_reason);
	}

	/* (non-Javadoc)
	 * @see com.shaoshaohuo.app.framework.IViewFramework#initData()
	 */
	@Override
	public void initData() {
		Intent fromIntent = getIntent();
		String result = fromIntent.getStringExtra(KEY_RESULT);
		if (VALUE_SUCCESS.equals(result)) {
			layoutSuccess.setVisibility(View.VISIBLE);
			String money = fromIntent.getStringExtra(KEY_MONEY);
			String payWay = fromIntent.getStringExtra(KEY_PAY_WAY);
			String orderId = fromIntent.getStringExtra(KEY_ORDER_ID);
			String payTime = fromIntent.getStringExtra(KEY_PAY_TIME);
			tvPayMoney.setText(money == null ? "" : money);
			tvPayWay.setText(payWay);
			tvPayOrderId.setText(orderId == null ? "" : orderId);
			tvPayTime.setText(payTime == null ? "" : payTime);
		} else if (VALUE_FAILURE.equals(result)) {
			layoutFailure.setVisibility(View.VISIBLE);
			String payFailureReason = fromIntent.getStringExtra(KEY_FAILURE_REASON);
			tvPayFailureReason.setText(payFailureReason);
		}
		contextForward = getIntent().getStringExtra(FORWARD_KEY);
	}

	/* (non-Javadoc)
	 * @see com.shaoshaohuo.app.framework.IViewFramework#initListener()
	 */
	@Override
	public void initListener() {
		topBar.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				if (FORWARD_USER_MAIN.equals(contextForward)) {
				}
				finish();
			}
		});
	}

}
